home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-01 | 7.3 KB | 401 lines | [TEXT/sLiN] |
- ! Version 3.0
- !
- !$ Use this script with TelePort Class 1 fax software working in the "numeric answers"
- !$ mode (FaxSTF,Faxilitate), ARA 1.0 or 2.0,
- !$ and a BBS, E-mail or other communication server software
- !
- ! A cable for hardware handshaking is required -??
-
- ^2 Fax Software: = Enum("FaxSTF™"="0","Faxilitate"="1","GlobalFax"="2") "0"
- ! ------------------------------------------
- ! Resetting the modem:
- ! ------------------------------------------
- @Hangup
- SetTries 2
- HsReset 0,0,17,19,0,0
- !
- ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
- ! to enter the command mode
- !
- @Label 1
- Flush
- matchclr
- matchstr 1 2 "OK\r\n"
- ChrDelay 1
- write "ATH0V1Q0\r"
- matchread 20
- Write "+++"
- ChrDelay 0
- DtrClear
- SBreak
- DtrSet
- !
- DecTries
- IfTries 1 1
- SerReset 2400,0,8,1
- IfTries 0 1
- SerReset 19200,0,8,1
- !
- ! OSErr -6019 "Modem error - the modem is not responding"
- exit -6019
- @Label 2
- ChrDelay 0
- write "AT&F+FCLASS=0;+FAE=0\r"
- SetSpeed 2400
- Jsr 100
- exit 0
-
- ! ------------------------------------------
- ! Receiving incoming calls
- ! ------------------------------------------
- @ANSWER
- SerReset 2400,0,8,1
- Jsr 80
- Write "ATIS22?\r"
- MatchClr
- MatchStr 1 8 "\r\n^$\r\n"
- MatchRead 20
- exit -6019
- @Label 8
- SetInfo 0 "^$"
- MatchClr
- MatchStr 1 9 "\r\n^$\r\n"
- MatchRead 20
- exit -6019
- @Label 9
- SetSReg 22 Val("^$")
- Jsr 100
- !
- ! Set the modem preferred speed first
- @Label 10
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the speaker and S0
- GetCommand B "Fax" "M"
- GetCommand C "Fax" "L"
- GetCommand D "Fax" "S0"
- SetVar A "S0=2"
- ifStr D 11 "S0=0"
- ifStr D 11 ""
- SetVar A "^D"
- @Label 11
- Write "AT^A^B^C+FAE=1\r"
- Jsr 100
- Write "ATV0+FCLASS=0\r"
- Jsr 110
- !
- ! Set the data options
- Jsr 75
- !
- ! Everything is ready - let's sit and wait for a data call
- ! We'll wait for 2 minutes, then reinitiate the modem
- !
- Note "Waiting for a Fax/ARA/Data call…"
- @Label 12
- MatchClr
- MatchStr 1 14 "2\r"
- MatchStr 2 15 "13\r"
- MatchStr 3 40 "15\r"
- MatchStr 4 13 "4\r"
- MatchRead 1200
- @Label 13
- Write "ATV1\r"
- Jsr 100
- SetSpeed 2400
- Jump 10
- !
- ! "2" ("RING") has been read
- @Label 14
- Note "Ring…"
- Jump 12
-
- ! "13" ("DATA") has been read
- @Label 15
- Write "ATV1O0\r"
- MatchClr
- MatchStr 1 16 "CONNECT ^$\r\n"
- MatchRead 30
- exit -6019
- @Label 16
- SetVar B "^$"
- SetSpeed Val("^B")
-
- IfOpen "Data" 21
- Jump 30
- @Label 21
- IfOpen "ARA" 22
- Jump 35
- @Label 22
- Note "Waiting for an ARA frame"
- MatchClr
- MatchStr 1 23 "^$\r"
- MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
- MatchStr 3 29 "\01\27\02\29\01\02\01\06"
- MatchRead 40
- Jump 24
- @Label 23
- QueueInput "^$\r"
- @Label 24
- Note "Non-ARA call"
- Jump 35
-
- @Label 28
- Note "ARA 1.0 call"
- Jump 30
- @Label 29
- Note "ARA 2.0 call"
- Jump 30
-
- @Label 30
- QueueInput "\r\nCONNECT ^B\r\n"
- @Label 31
- IfOriginate 32
- QueueInput "\r\nRING\r\n"
- @Label 32
- Attach "ARA" (DTR)
-
- @Label 35
- GetSReg C "DATA" 4
- QueueInput "\r^CCONNECT ^B\r^C"
- ifOriginate 36
- QueueInput "\r^CRING\r^C"
- @Label 36
- Attach "Data" (DTR,Escape,Break)
-
- !
- ! Receiving Fax calls
- !
- @Label 40
- SetSpeed 19200
- MatchClr
- MatchStr 1 41 "1\r"
- MatchRead 300
- exit -6019
- @Label 41
- !
- ! Fax connection has been established (we read "CONNECT")
- ! Put the CONNECT ("1\r") back to the buffer,
- ! if it was an incoming call, put the "RING" before it
- @Label 45
- QueueInput "1\r"
- ifOriginate 47
- @Label 46
- QueueInput "2\r2\r"
- @Label 47
- Attach "Fax" (DTR,Reset(2400),IdleLimit=30)
-
- ! ------------------------------------------
- ! Originating a call through the "ARA" subport
- ! ------------------------------------------
- @ORIGINATE "ARA"
- SerReset 2400,0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- Jsr 75
- !
- ! dial the number
- Write "ATD^1\r"
- !
- ! Wait for a modem response
- Jsr 90
- IfStr C 30 "DATA"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "DATA" subport
- ! ------------------------------------------
- @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
- SerReset 2400,0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- Jsr 75
- !
- ! dial the number
- Write "ATD^1\r"
- HsReset *
- !
- ! Wait for a modem response
- Jsr 90
- IfStr C 35 "DATA"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "Fax" subPort
- ! ------------------------------------------
- @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
- !
- ! Set the "Fax" speed
- !
- SerReset 19200,0,8,1
- Jsr 80
- !
- ! Set the common options
- !
- Jsr 70
- !
- ! Set the Fax mode (Xon/Xoff)
- Write "AT+FCLASS=1\r"
- Jsr 100
- !
- ! Now emit all commands that the application has sent to that port,
- ! except "FCLASS", etc
- !
- EmitClear "+FCLASS","V","E"
- Jsr 60
- !
- ! Prepare to receive all error result codes, dial the number
- !
- Write "ATV0D^1\r"
- HsReset *
- Jsr 85
- IfStr C 45 "FAX"
- Write "\r"
- Exit -6019
- !
- !
- ! This section emits all modem commands sent from the client application
- ! For each set of commands the "OK" answer is awaited
- !
- @Label 60
- EmitStart
- @Label 61
- EmitCommand 62
- Jsr 100
- Jump 61
- @Label 62
- return
- !
- ! This section initiates the modem before ANSWER and ORIGINATEs:
- ! extended responses + connect at the highest rate + speaker control +
- ! reset on Dtr drop + DCD valid
- ! Verbal responses mode, no echo
- !
- @Label 70
- Write "AT&D2&C1V1E0\r"
- Jsr 100
- return
-
- ! Set the communication options:
- ! • Normal/AUTO Connection
- ! • HW flow control (for ARA, Fax should not use a handshake on receiving)
- ! • CONNECT <DCE speed> or CARRIER/CONNECT
- @Label 75
- return
-
- !
- ! This section syncronize the modem after the serial port speed switching
- !
- @Label 80
- ChrDelay 1
- Write "AT\r"
- ChrDelay 0
- Jsr 100
- return
- !
- ! Error Codes
- @Label 81
- exit -6020
- @Label 82
- exit -6022
- @Label 83
- exit -6021
- @Label 84
- exit -6023
-
- !
- ! Connecting in the numeric mode (fax)
- ! On exit:
- ! ^C contains "NONE" if no connection has been established
- @Label 85
- MatchClr
- MatchStr 1 88 "1\r"
- MatchStr 2 87 "2\r"
- MatchStr 5 81 "6\r"
- MatchStr 6 82 "7\r"
- MatchStr 7 83 "3\r"
- MatchStr 8 84 "8\r"
- @Label 86
- Matchread 1200
- SetVar C "NONE"
- return
-
- @Label 87
- Note "Ring…"
- Jump 86
- @Label 88
- SetVar C "FAX"
- return
-
- !
- ! This subroutine waits for the modem response (data mode)
- ! On exit:
- ! ^A contains the protocol used
- ! ^B contains the carrier speed
- ! ^C contains "NONE" if no connection has been established
- ! If modem reports an error, the scripts exits with an error code
- !
- @Label 90
- SetVar A "NONE"
- SetVar B ""
- MatchClr
- Matchstr 5 97 "CONNECT ^$\r\n"
- Matchstr 6 94 "RING\r\n"
- Matchstr 10 82 "BUSY\r\n"
- MatchStr 11 83 "NO CARRIER\r\n"
- MatchStr 12 84 "NO ANSWER\r\n"
- @Label 91
- Matchread 1200
- SetVar C "NONE"
- return
-
- @Label 94
- Note "Ring…"
- Jump 91
-
-
- ! CONNECT xxx was detected
- @Label 97
- SetVar B "^$"
- SetVar C "DATA"
- return
- !
- ! Processing an AT command:
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 100
- MatchClr
- MatchStr 1 103 "\r\nOK\r\n"
- MatchStr 2 102 "\r\nERROR\r\n"
- @Label 101
- MatchRead 20
- @Label 102
- Exit -6019
- @Label 103
- return
-
- !
- ! Processing an AT command in the numeric mode
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 110
- MatchClr
- MatchStr 1 103 "0\r"
- MatchStr 2 102 "4\r"
- Jump 101
-